package com.imu.purse.modules.base.dao;

import java.util.List;
import org.apache.ibatis.annotations.Select;

import com.imu.core.base.BaseMapper;
import com.imu.purse.modules.base.entity.UserLoginEntity;

/**
 * 用户登录记录
 * @author sunhongwei
 * @email sunhongwei@jshijian.com
 * @date 2017-11-08 10:31:21
 * Copyright (c) 2017 武汉极时间科技有限公司 版权所有 
 * Jshijian aloha CO.,LTD. All Rights Reserved. 
 */
public interface UserLoginMapper extends BaseMapper<UserLoginEntity>
{
	/**
     * 分页查询
     * @param pageNo 页号
     * @param pageSize 每页显示记录数
     * @return
     */
	@Select({
		"<script>",
		    "SELECT id,",
					"user_id, ",
					"app_id, ",
					"os, ",
					"os_ver, ",
					"dev_name, ",
					"dev_code, ",
					"account, ",
					"token, ",
					"time_create",
		    "FROM imu_user_login ",
		    "WHERE 1 = 1 ",
			"<when test = 'userId != null'>",
		    	"AND `user_id` = #{userId}",
		    "</when>",
			"<when test = 'account != null'>",
		    	"AND `account` LIKE CONCAT('%',#{account},'%')",
		    "</when>",
			"<when test = 'token != null'>",
		    	"AND `token` LIKE CONCAT('%',#{token},'%')",
		    "</when>",
		    "<when test = 'sts != null'>",
		    	"AND time_create &gt;= #{sts}",
		    "</when>",
		    "<when test = 'ets != null'>",
				"AND time_create &lt;= #{ets}",
			"</when>",
		    "ORDER BY time_create DESC",
    	"</script>"
	})
    public List<UserLoginEntity> findByPage(final UserLoginEntity entity);	
}
